export default {
    namespaced: true,
    state: {
        list: [],
    },
    getters: {
        msgLength: state => state.list.length,
    },
    actions: {
        setInmailLenght: ({
            commit,
            dispatch
        }, data) => commit('SET_INMAIL_LIST', data),
        // 读取消息
        readMsg: ({
            commit,
            dispatch
        }, msgId) => {
            commit('DEL_MSG', msgId)
        }
    },
    mutations: {
        SET_INMAIL_LIST(state, data) {
            state.list = data
        },
        DEL_MSG(state, msgId) {
            if (msgId && state.list.length > 0){
                if (state.list.findIndex(item => item.id === msgId) > -1){
                    state.list.splice(state.list.findIndex(item => item.id === msgId),1)
                }
            }
        }
    }
}